/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "orden_compra", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdenCompra.findAll", query = "SELECT o FROM OrdenCompra o"),
    @NamedQuery(name = "OrdenCompra.findByOrdenCopraCod", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraPK.ordenCopraCod = :ordenCopraCod"),
    @NamedQuery(name = "OrdenCompra.findByIdordenCompra", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraPK.idordenCompra = :idordenCompra"),
    @NamedQuery(name = "OrdenCompra.findByIdcompraCab", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraPK.idcompraCab = :idcompraCab"),
    @NamedQuery(name = "OrdenCompra.findByCompraCabFecha", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraPK.compraCabFecha = :compraCabFecha"),
    @NamedQuery(name = "OrdenCompra.findByCompraCabNroFactura", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraPK.compraCabNroFactura = :compraCabNroFactura"),
    @NamedQuery(name = "OrdenCompra.findByCompraCabIdproveedores", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraPK.compraCabIdproveedores = :compraCabIdproveedores"),
    @NamedQuery(name = "OrdenCompra.findByOrdenCompraCabDescrip", query = "SELECT o FROM OrdenCompra o WHERE o.ordenCompraCabDescrip = :ordenCompraCabDescrip")})
public class OrdenCompra implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OrdenCompraPK ordenCompraPK;
    @Column(name = "orden_compra_cab_descrip")
    private Integer ordenCompraCabDescrip;
    @JoinColumns({
        @JoinColumn(name = "idcompra_cab", referencedColumnName = "idcompra_cab", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "compra_cab_fecha", referencedColumnName = "fecha", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "compra_cab_nro_factura", referencedColumnName = "nro_factura", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "compra_cab_idproveedores", referencedColumnName = "idproveedores", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private CompraCab compraCab;
    @JoinColumn(name = "idorden_compra", referencedColumnName = "idorden_compra", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private OrdenCompraCab ordenCompraCab;

    public OrdenCompra() {
    }

    public OrdenCompra(OrdenCompraPK ordenCompraPK) {
        this.ordenCompraPK = ordenCompraPK;
    }

    public OrdenCompra(int ordenCopraCod, int idordenCompra, int idcompraCab, int compraCabFecha, int compraCabNroFactura, int compraCabIdproveedores) {
        this.ordenCompraPK = new OrdenCompraPK(ordenCopraCod, idordenCompra, idcompraCab, compraCabFecha, compraCabNroFactura, compraCabIdproveedores);
    }

    public OrdenCompraPK getOrdenCompraPK() {
        return ordenCompraPK;
    }

    public void setOrdenCompraPK(OrdenCompraPK ordenCompraPK) {
        this.ordenCompraPK = ordenCompraPK;
    }

    public Integer getOrdenCompraCabDescrip() {
        return ordenCompraCabDescrip;
    }

    public void setOrdenCompraCabDescrip(Integer ordenCompraCabDescrip) {
        this.ordenCompraCabDescrip = ordenCompraCabDescrip;
    }

    public CompraCab getCompraCab() {
        return compraCab;
    }

    public void setCompraCab(CompraCab compraCab) {
        this.compraCab = compraCab;
    }

    public OrdenCompraCab getOrdenCompraCab() {
        return ordenCompraCab;
    }

    public void setOrdenCompraCab(OrdenCompraCab ordenCompraCab) {
        this.ordenCompraCab = ordenCompraCab;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ordenCompraPK != null ? ordenCompraPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenCompra)) {
            return false;
        }
        OrdenCompra other = (OrdenCompra) object;
        if ((this.ordenCompraPK == null && other.ordenCompraPK != null) || (this.ordenCompraPK != null && !this.ordenCompraPK.equals(other.ordenCompraPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.OrdenCompra[ ordenCompraPK=" + ordenCompraPK + " ]";
    }
    
}
